package com.asialjim.wechat.official.apiservice.impl;

import com.asialjim.wechat.core.executor.WeChatApiExecutor;
import com.asialjim.wechat.official.api.OfficialApi;
import com.asialjim.wechat.official.api.qrcode.GetQrCodeTicketApiRequest;
import com.asialjim.wechat.official.api.qrcode.GetQrCodeTicketApiResponse;
import com.asialjim.wechat.official.apiservice.QrCodeService;
import com.asialjim.wechat.official.qrcode.QrCode;
import com.asialjim.wechat.official.qrcode.QrCodeProperty;
import lombok.AllArgsConstructor;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: QrCodeServiceImpl ]</i></h2><strong>
 * <p> qr code service
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/3/31   &nbsp;&nbsp; JDK 8
 */
@AllArgsConstructor
public class QrCodeServiceImpl implements QrCodeService {
    private final WeChatApiExecutor apiExecutor;

    @Override
    public QrCode createQrCode(QrCodeProperty qrCodeProperty) {

        GetQrCodeTicketApiRequest.BodyParam apiReqParam = qrCodeProperty.createApiReqParam();
        GetQrCodeTicketApiResponse response = apiExecutor.execute(OfficialApi.GET_QRCODE_TICKET, null, apiReqParam, GetQrCodeTicketApiResponse.class).parse();

        return QrCode.createQrCode(response);
    }
}